<template>
	<view class="ljapp check-list">
		<view class="content">
			<view class="list" v-if="group.list.length>0">
				<view class="card" v-for="(item,index) in group.list" :key="index" @click="Onpages('/pagesL/check/info?order_code='+item.order_code)">
					<view class="head u-flex u-flex-between">
						<view class="cell u-flex u-flex-y-center">
							<view class="label">检测编号：</view>
							<view>{{item.order_code}}</view>
						</view>
						<view class="status0" v-if="item.status==0">待选机构</view>
						<view class="status1" v-else-if="item.status==1">预约成功</view>
						<view class="status2" v-else-if="item.status==2">已完成</view>
						<view class="status-1" v-else-if="item.status==-1">已取消</view>
						<view class="status3" v-else-if="item.status==3">已过期</view>
					</view>
					<view class="cellbox">
						<view class="cell u-flex u-flex-y-center">
							<view class="label">检测时间：</view>
							<view>{{item.time}}</view>
						</view>
						<view class="cell u-flex u-flex-y-center">
							<view class="label">检测机构：</view>
							<view>
								<view class="u-flex" v-if="item.status==0">
									<view style="color: #ebb966;" @click.stop="onOctSelect(item)">未选择机构，去选择机构</view>
									<u-icon name="arrow-right" color="#ebb166"></u-icon>
								</view>
								<view v-else-if="item.oct_info&&item.oct_info.id">
									{{item.oct_info.name}}
								</view>
								<view class="u-flex" v-else>
									<view>未选择机构</view>
								</view>
							</view>
						</view>
						<view class="cell u-flex u-flex-y-center">
							<view class="label">姓　　名：</view>
							<view>{{item.name}}</view>
						</view>
						<view class="cell u-flex u-flex-y-center">
							<view class="label">性　　别：</view>
							<view>{{item.sex==1?'男':'女'}}</view>
						</view>
						<view class="cell u-flex u-flex-y-center">
							<view class="label">联系方式：</view>
							<view>{{item.mobile}}</view>
						</view>
					</view>
				</view>
			</view>
			<lj-empty v-else-if='!loading'>暂无预约信息~</lj-empty>
			<view v-if="loading || group.list.length > 0">
				<u-loadmore
					:status="loading?'loading':(group.loaded?'nomore':'loadmore')"
					fontSize="12"
					color="#ccc"
					nomoreText="已加载全部"
					marginTop="40rpx"
					@loadmore="getList"
				></u-loadmore>
			</view>
		</view>
	</view>

</template>

<script>
	export default {
		data() {
			return {
				group:{
					page: 1,
					limit: 10,
					list: [],
					loaded: false
				},
				loading: false,
			}
		},
		onLoad() {
		},
		onShow() {
			this.init()
		},
		methods: {
			init(){
				this.group.list = []
				this.group.page = 1
				this.group.loaded = false
				this.loading = false
				
				this.getList()
			},
			getList() {
				var that = this,group = that.group;
				if(that.loading || group.loaded) return;
				
				that.loading = true
				
				let data = {
					page: group.page,
					limit: group.limit,
				}
				this.$Http({
					url: 'physicalOrderListnew',
					data: data,
					load: false
				}).then(res => {
					if (res.code == 1) {
						var list = res.data;
						group.loaded = list.length < group.limit;
						group.page ++;
						group.list = group.list.concat(list);
					}
					that.loading = false
				}).catch(()=>{
					that.loading = false
				});
			},
			
			//页面跳转
			Onpages(e) {
				uni.navigateTo({
					url: e,
				})
			},
			onOctSelect(item){
				uni.navigateTo({
					url: '/pagesL/check/octSelect?order_code='+item.order_code
				})
			},
		}
	}
</script>

<style lang="less">
	@import '@/pagesL/style.less';
	
	.status-1{
		color: #999999;
	}
	.status0{
		color: #EBB966;
	}
	.status1{
		color: #12B3F1;
	}
	.status2{
		color: #19A752;
	}
	.status3{
		color: #999999;
	}
</style>
